import os
path = os.getcwd()
dirs = os.listdir(path)
total_lines = []
for dir in dirs:
    if ".txt" in dir:
        f1 = open(path+"\\"+dir,"r",encoding="utf-8")
        text_lines = f1.readlines()
        #print(dir+" "+str(len(dir)))
        f1.close()
        for line in text_lines:
            total_lines.append(line)
        continue
with open(path+"\\dmzj_info_yuri.txt","w",encoding="utf-8") as f2:
    for line in total_lines:
        print(line)
        f2.write(line[line.find("id\":")+4:line.find(",")]+" ")
        str1 = line[line.find("title\":\"")+8:]
        f2.write("標題:"+str1[:str1.find("\"")]+" ")
        str2 = str1[str1.find("authors\":\"")+10:]
        f2.write("作者"+str2[:str2.find("\"")]+" ")
        if "\\u8fde\\u8f7d\\u4e2d" in line:
            f2.write("連載中"+"\n")
        else:
            f2.write("已完結"+"\n")
    f2.close()